package com.example.zsf;

import android.app.Application;
import android.content.Context;

import com.blankj.utilcode.util.Utils;
import com.danikula.videocache.HttpProxyCacheServer;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.tencent.bugly.crashreport.CrashReport;
import com.tendcloud.tenddata.TCAgent;

import cn.jpush.android.api.JPushInterface;

public class ZSFApplication extends Application {
    private static Application instance;
    private HttpProxyCacheServer proxy;
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        Utils.init(this);
        Logger.addLogAdapter(new AndroidLogAdapter());
        CrashReport.initCrashReport(getApplicationContext(), "2f7e5288cd", true);

        TCAgent.LOG_ON=true;
        TCAgent.init(this, "574B83ED6E864754AD6997344FE7852C", "Android");
        TCAgent.setReportUncaughtExceptions(true);


        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
    }

    public static Application getInstance() {
        return instance;
    }


    public static HttpProxyCacheServer getProxy(Context context) {
        ZSFApplication app = (ZSFApplication) context.getApplicationContext();
        return app.proxy == null ? (app.proxy = app.newProxy()) : app.proxy;
    }

    private HttpProxyCacheServer newProxy() {
        return new HttpProxyCacheServer.Builder(this)
                .maxCacheSize(1024 * 1024 * 1024)       // 1 Gb for cache
                .build();
    }

}
